//
//  KZEvaluateResultView.m
//  听说弱点强化训练
//
//  Created by 朱凯 on 2018/10/22.
//  Copyright © 2018年 盛超. All rights reserved.
//

#import "KZEvaluateResultView.h"

@implementation KZEvaluateResultView
{
    UIView *_bgView;
    UIImageView  *_statusIconView;
    
    BOOL _isSuccess;
}

- (instancetype)initWithStatus:(BOOL)isSuccess {
    
    if (self = [super init]) {
        
        
        self.backgroundColor = UIColor.whiteColor;
        _isSuccess = isSuccess;
        [self setupUI];

    }
    return self;
}

- (void)setupUI {
    
    _bgView = UIView.new;
    [self addSubview:_bgView];
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(4 + 2);
        make.right.bottom.mas_equalTo(-4 - 2);
    }];
    
    _statusIconView = [UIImageView new];
    [_bgView addSubview:_statusIconView];
    [_statusIconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.equalTo(_bgView).multipliedBy(0.5);
        make.center.equalTo(_bgView);
    }];
    
    // 阴影
    self.layer.shadowOffset = CGSizeMake(0, 0);
    self.layer.shadowRadius = 15;
    self.layer.shadowOpacity = 0.6;
    
    if (_isSuccess) {
        _bgView.backgroundColor = KZThemeColor;
        self.layer.shadowColor = KZThemeColor.CGColor;
        _statusIconView.image = [UIImage imageNamed:@"kz-合格"];
    } else {
        _bgView.backgroundColor = UIColor.orangeColor;
        self.layer.shadowColor = UIColor.orangeColor.CGColor;
        _statusIconView.image = [UIImage imageNamed:@"kz-不合格"];
    }
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.layer.cornerRadius = self.width / 2;
    _bgView.layer.cornerRadius = self.width / 2 - 4 - 2;

}


@end
